package dialog;

import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.example.zx.theline.R;

import base.BaseDialog;

/**
 * Created by Ren on 2017/8/10.
 */

public class CenterDialog extends BaseDialog {

    TextView message;
    TextView confirm;
    TextView cancel;

    CenterClick mCenterClick;

    String s="这是一个默认提示消息";

    public CenterDialog(Context context) {
        super(context);
    }

    public CenterDialog(Context context, CenterClick centerClick) {
        super(context);
        this.mCenterClick = centerClick;

    }

    public CenterDialog(Context context, int themeResId) {
        super(context, themeResId);

    }

    protected CenterDialog(Context context, boolean cancelable, OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);

    }


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        InitView();
        InitData();
        InitListen();
    }

    @Override
    protected void InitView() {
        setContentView(R.layout.dialog_center);
        message = (TextView) findViewById(R.id.message);
        confirm = (TextView) findViewById(R.id.confirm);
        cancel = (TextView) findViewById(R.id.cancel);


    }

    @Override
    protected void InitData() {

        message.setText(s);
    }

    @Override
    protected void InitListen() {

        confirm.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mCenterClick.confirmListener();
            }
        });
        cancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mCenterClick.cancelListener();
                CenterDialog.this.dismiss();
            }
        });

    }

    public void setMessage(String s) {
      this.s=s;
    }


    public interface CenterClick {
        void confirmListener();
        void cancelListener();
    }

}
